package study.web.service.cxf.client;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import study.web.service.cxf.SupportCity;
import study.web.service.cxf.WeatherInterface;

/**  
* @Name: WeatherClient
* @Description: 便民网站天气预报WebServices支持的国内外城市或地区信息获取客户端
* @Author: 李超
* @Create Date: 2017-01-07
*/
public class WeatherClient {
	
	public static void main(String[] args) throws MalformedURLException {
		//1、创建ws服务访问的url
		URL url = new URL("http://localhost:8080/cxf_spring_server/ws/weather?wsdl") ;
		//2、创建ws服务的限定名称
		QName qName = new QName("http://cxf.service.web.study", "WeatherService") ;
		//3、创建ws服务视图
		Service service = Service.create(url, qName) ;
		//4、获取portType接口
		WeatherInterface weatherInterface = service.getPort(WeatherInterface.class) ;
		//调用服务
		List<SupportCity> list = weatherInterface.querySupportCity("河南") ;
		for (SupportCity supportCity : list) {
			System.out.println(supportCity.getCityName());
		}
	}

}
